package com.vueadmin.zxn.controller;

import com.vueadmin.zxn.common.result.Result;
import com.vueadmin.zxn.model.Room;
import com.vueadmin.zxn.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/room")
public class RoomController {

    @Autowired
    private RoomService roomService;

    @RequestMapping("/eee")
    public Result aa() {
        Room room =  roomService.getById("1111");
        return Result.success(room);
    }

    @RequestMapping("/add")
    public Result add(@Validated @RequestBody Room room){
        roomService.addRoom(room);
        return Result.success();
    }

    @RequestMapping("/list")
    public List<Room> list(){
        return roomService.getall();
    }

    @RequestMapping("/count")
    public long count(){
        return roomService.count();
    }
}
